package com.ning.weixin.service.impl;

import com.ning.weixin.mapper.Oauth2TokenMapper;
import com.ning.weixin.service.Oauth2TokenService;
import com.ning.weixin.utils.wxUtils.Oauth2Token;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Oauth2TokenServiceImpl implements Oauth2TokenService {

    @Autowired
    private Oauth2TokenMapper mapper;

    @Override
    public void saveAccessToken(Oauth2Token oauth2Token) {
        if (oauth2Token != null) {
            mapper.saveAccessToken(oauth2Token);
        }
    }

    @Override
    public Oauth2Token findTokenById(String openId) {
        if (openId != null) {
            Oauth2Token result = mapper.findTokenById(openId);
            return result;
        }
        return null;
    }
}
